<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();

jimport( 'joomla.application.component.view' );

class JAJobBoardViewJATax extends JAView 
{
	/**
	 * Hellos view display method
	 * @return void
	 **/
	function display($tpl = null)
	{
		$task = JRequest::getVar("task", '');
		$tab = JRequest::getVar("tab", 'global');
		
		switch ($tab){
			case "global":
				$this->setLayout("global");
				$this->displayGlobal($tpl);
				break;
			case "region":
				switch ($task){
					case 'add':
					case 'edit':				
						$this->displayForm($tpl);
						break;
					case 'list_code':
						$this->displayListCode($tpl);
						break;
					case 'edit_code':
						$this->displayEditCode($tpl);
						break;	
					default:
						$this->displayListItems($tpl);
				}
				break;
		}
	}
	
	/**
  	* Display Global setting
  	*/
  	function displayGlobal($tpl){  	
  		global $mainframe, $jbconfig;
  		
  		if( !isset($jbconfig['tax']) ){
  			$jbconfig['tax'] = new JParameter("");  			
  		}
		$this->assignRef('params', $jbconfig['tax']);
		
		parent::display($tpl);	
  	}
	
	/**
  	* Display List of items
  	*/
  	function displayListItems($tpl){  	
  		global $mainframe;

  		$lists = &$this->get('var');
		$total = &$this->get('countcredit');
		jimport('joomla.html.pagination');
		$pageNav = new JPagination( $total, $lists['limitstart'], $lists['limit'] );

		$items = &$this->get('Items');
		
		$this->assignRef('items', $items);
		$this->assignRef('lists', $lists);
		$this->assignRef('pageNav', $pageNav);

		parent::display($tpl);	
  	}
  	
  	/**
  	* Display List of codes
  	*/
  	function displayListCode($tpl){  	
  		global $option, $jbconfig;
		
		$cids = JRequest::getVar('cid',  0, '', 'array');
		$cid = (int)$cids[0];
		
		$listcode = &$this->get('ListCode');
		
		$this->assignRef('listcode', $listcode);
        
		$this->assign('option', $option);
		parent::display($tpl);	
  	}
  	
  	/**
  	* Display Edit of codes
  	*/
  	function displayEditCode($tpl){  	
  		global $option, $jbconfig;
				
		$item = &$this->get('CodeItem');
		
		$this->assignRef('item', $item);
        
		$this->assign('option', $option);
		parent::display($tpl);	
  	}
  	  		
	function displayForm($tpl)
	{
		global $option, $jbconfig;
		
		$cids = JRequest::getVar('cid',  0, '', 'array');
		$cid = (int)$cids[0];
		
		$row = $this->get('Item');	
		
		$this->assign('row', $row);
		$this->assign('option', $option);
		$this->assign('config', $jbconfig);

		parent::display($tpl);
	}
	
	function getTaxTabs(){
		global $option;
  		$type = JRequest::getVar('tab','global');
  		$tabs = '<div class="submenu-box">
						<div class="submenu-pad">
							<ul id="submenu" class="configuration">';
  		
  		$tabs.= '<li><a href="index.php?option='.$option.'&view=jaconfiguration&tab=tax"';
		if ($type == 'global') {
			$tabs .= ' class="active" ';
		}
		$tabs.=	'>';
		$tabs.=	JText::_( 'Global TAX Setting' ).'</a></li>';
		
		$tabs.= '<li><a href="index.php?option='.$option.'&view=jatax&tab=region"';
		if ($type == 'region') {
			$tabs .= ' class="active" ';
		}
		$tabs.=	'>';
		$tabs.=	JText::_( 'Regional TAX Setting' ).'</a></li>';		
		
		$tabs.=	'				</ul>
							<div class="clr"></div>
						</div>
					</div>
					<div class="clr"></div>';
		return $tabs;
  	}
}
